<?php

class Admin_RoomcatsController extends Zend_Controller_Action
{

    public function init()
    {
        /* Initialize action controller here */
    }

    public function indexAction()
    {
    	//echo "This is roomcat controller";exit;
       $this->_helper->layout->setLayout('admin');	
       Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
       $roomcats_model = new roomcats();
       $roomcats_arr = $roomcats_model->listroomcats();
        //print_r($roomcats_arr); EXIT;
       $this->view->roomcats_arr = $roomcats_arr;
     
    }
    
    public function addAction()
    {
        $this->_helper->layout->setLayout('admin');	
		Zend_Loader::loadFile('../application/admin/forms/Roomcats.php');
        $Roomcats_form = new Form_Roomcats();
        $this->view->title = "Add new Room Category";
        
        $this->view->Roomcats_form = $Roomcats_form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($Roomcats_form->isValid($formData)) {
            	//print_r($formData);
	           Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
	           $Roomcats_model = new Roomcats();
	           $Roomcats_model->addRoomcats($formData['Roomcats_dsc'],$formData['is_enabled']);
	           $this->_helper->redirector('index');
            } else {
                $Roomcats_form->populate($formData);
            }
        }
            
    }

    public function editAction()
    {
    	$this->_helper->layout->setLayout('admin');	
        Zend_Loader::loadFile('../application/admin/forms/Roomcats.php');
        $Roomcats_form = new Form_Roomcats();
        $this->view->form = $Roomcats_form;
        
        if ($this->getRequest()->isPost()) {
            $formData = $this->getRequest()->getPost();
            if ($Roomcats_form->isValid($formData)) {
                Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
                $Roomcats_model = new Roomcats();
                $Roomcats_model->updateRoomcats($formData['roomcat_id'],$formData['Roomcats_dsc'],$formData['is_enabled']);
                
                $this->_helper->redirector('index');
            } else {
                $form->populate($formData);
            }
        } else {
            $Roomcats_id = $this->_getParam('roomcat_id', 0);
            
            if ($Roomcats_id > 0) {
                Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
                $Roomcats_model = new Roomcats();
               // print_r($Roomcats_model->getRoomcats($Roomcats_id));
                //$Roomcats_form->populate($Roomcats_model->getRoomcats($Roomcats_id));
                $roomcats_arr=$Roomcats_model->getRoomcats($Roomcats_id);
               $this->view->roomcats_arr = $roomcats_arr;
            }
        }
        
    }

    /*public function deleteAction()
    {
      $this->_helper->layout->setLayout('admin');	
        if ($this->getRequest()->isPost()) {
            $del = $this->getRequest()->getPost('del');
            if ($del == 'Yes') {
               $Roomcats_id = $this->getRequest()->getPost('id');
                Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
                $Roomcats_model = new Roomcats();
                $Roomcats_model->deleteRoomcats($Roomcats_id);
            }
            $this->_helper->redirector('index');
        } else {
            $Roomcats_id = $this->_getParam('Roomcats_id', 0);
            Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
            $Roomcats_model = new Roomcats();
            $this->view->Roomcats = $Roomcats_model->getRoomcats($Roomcats_id);
        }
    }*/
    
      public function deleteAction()
          {
               $this->_helper->layout->setLayout('admin');	
               $roomcat_id = $this->_getParam('roomcat_id', 0);
             // echo $hotel_id;exit;
                Zend_Loader::loadFile('../application/admin/models/Roomcats.php');
                $Roomcats_model = new Roomcats();
                $Roomcats_model->deleteRoomcats($roomcat_id);
                 $this->_helper->redirector('index');
      
       
           }
           
           



}







